<?php
//包含连接数据库的公共文件
require_once("./conn.php");
    //执行查询语句
    $sql="select * from insert_student order by son asc";
    $set=mysqli_query($con,$sql);
    //获取所有行数据
    $arrs = mysqli_fetch_all($set,MYSQLI_ASSOC);
    //获取学生人数
    $records = mysqli_num_rows($set);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生信息管理中心</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .show{
            width: 100%;
            height: 100vh;
            background:linear-gradient(to right, #29eac4, #4284db);
        }
        .show_title{
            color:white;
            text-align: center;
        }
        .show_title h2{
            padding-top: 100px;
            color: white;
            letter-spacing: 8pt;
        }
        .show_title a{
            display: block;
            margin-top: 30px;
            margin-bottom:20px;
            color: white;
            font-size: 18px;
            text-decoration: none;
        }
        table{
            width: 600px;
            margin: 50px auto;
            text-align: center;
            border:1px solid white;
            border-spacing: 5px;
        }
        tr{
            height: 50px;
        }
        tr th{
            color:white;
        }
        tr td{
            background: linear-gradient(to right,blue,red);
            -webkit-background-clip: text;
            color: transparent;
        }
        tr td a{
            background: linear-gradient(to right,blue,red);
            -webkit-background-clip: text;
            color: transparent;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="show">
        <div class="show_title">
            <h2>学生信息管理中心</h2>
            <a href="./index.html">返回首页</a>
            <a href="./add.html">添加学生</a>
            目前共有<span style="color: red"><?php echo "$records"?></span>个学生信息
        </div>
        <table rules="all" cellpadding="10">
            <tr>
                <th>学生学号</th>
                <th>学生姓名</th>
                <th>出生日期</th>
                <th>性别</th>
                <th>班级</th>
                <th>专业号</th>
                <th>操作选项</th>
            </tr>
            <?php
                //循环二维数组
                foreach($arrs as $arr){
            ?>
            <tr align="center">
                <td><?php echo $arr['son']?></td>
                <td><?php echo $arr['sname']?></td>
                <td><?php echo $arr['sbirth']?></td>            
                <td><?php echo $arr['ssex']?></td>            
                <td><?php echo $arr['sclass']?></td>            
                <td><?php echo $arr['zon']?></td>  
                <td>
                <a href="delete.php?son=<?php echo $arr['son']?>" onclick="return confirm('是否删除当前数据？')">删除</a>
                <a href="./show_up.php?son=<?php echo $arr['son']?>">修改</a>
                </td>          
            </tr>
            <?php }?>
        </table>
    </div>
</body>
</html>